import os

basedir = os.path.abspath(os.path.dirname(__file__))
class Config:
    DATA_DIR = './data'
    if os.path.exists(DATA_DIR) == False:
        os.mkdir(DATA_DIR)
    
    SECRET_KEY = 'FLASK APP SECRET'
    
    SESSION_KEY = 'FLASK APP SESSION'
    SESSION_TYPE = 'filesystem'
    SESSION_FILE_DIR = os.path.join(basedir, f'{DATA_DIR}/flask_sessions')
    
    DEBUG=True
    # SQLALCHEMY_DATABASE_URI = f"sqlite:///sqlite-app.db"
    SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, f'{DATA_DIR}/app.sqlite')
    SQLALCHEMY_ECHO = False
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    
    # form表单中的验证码的配置
    RECAPTCHA_PUBLIC_KEY = '124ffafa'
    RECAPTCHA_PRIVATE_KEY = 'faeafefaae'
    RECAPTCHA_PARAMETERS = {'hl': 'zh', 'render': 'explicit'}
    RECAPTCHA_DATA_ATTRS = {'theme': 'dark'}
    
    # log配置
    LOG_DIR = f'{DATA_DIR}/logs'
    if os.path.exists(os.path.join(basedir,LOG_DIR)) is False:
        os.mkdir(os.path.join(basedir,LOG_DIR))
    LOG_FILE = os.path.join(basedir,LOG_DIR + '/log.log')
    
    BOOTSTRAP_SERVER_LOCAL = True # 设置为加载本地资源
    BOOTSTRAP_SERVER_CDN = False
    
    # 项目的路径
    BASE_DIR = os.path.dirname(os.path.abspath(__file__))
    
    # 静态文件夹路径
    STATIC_DIR = os.path.join(BASE_DIR, './apps/static')
    TEMPLATE_DIR = os.path.join(BASE_DIR, './apps/templates')
    
    # 头像的上传目录
    UPLOAD_ICON_DIR = os.path.join(STATIC_DIR, './upload/icon')
    
    # 相册的上传目录
    UPLOAD_PHOTO_DIR = os.path.join(STATIC_DIR, './upload/photo')
    
    # 验证码保存的目录
    CAPTCHA_DIR = os.path.join(STATIC_DIR, './captcha')

class Development(Config):
    ENV="development"
    

class Production(Config):
    ENV="production"
    DEBUG=False
    

if __name__ == '__main__':
    print(Config.BASE_DIR)
    print(Config.STATIC_DIR)